package com.evidencer.java.classes;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

import com.evidencer.java.domain.ReflectEntity;

public class ReflectDemo {

	/**
	 * @param args
	 * @throws ClassNotFoundException 
	 * @throws IllegalAccessException 
	 * @throws InstantiationException 
	 * @throws SecurityException 
	 * @throws NoSuchMethodException 
	 * @throws InvocationTargetException 
	 * @throws IllegalArgumentException 
	 * @throws NoSuchFieldException 
	 */
	public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchMethodException, SecurityException, IllegalArgumentException, InvocationTargetException, NoSuchFieldException {
		// TODO Auto-generated method stub
		/*
		 * ��һ�ֻ�ȡ������ֽ��룩�ķ���
		 * ͨ������getClass()����
		 */
//		ReflectEntity re=new ReflectEntity();
//		Class clazz=re.getClass();
//		
		/*
		 * �ڶ��ֻ�ȡ������ֽ��룩�ķ���
		 * ͨ���������.class����
		 */
		Class clazz2=ReflectEntity.class;
		
		/*
		 * �ڶ��ֻ�ȡ������ֽ��룩�ķ���
		 * ͨ������ Class.forName('classpath')
		 */
		Class clazz3=Class.forName("com.evidencer.java.bean.ReflectEntity");
		Constructor constructor=clazz3.getConstructor(int.class);
		Object obj=constructor.newInstance(30);
		Field f=clazz3.getDeclaredField("count");
		f.setAccessible(true);
		f.set(obj, 34);
		Method m=clazz3.getDeclaredMethod("getCountValue", null);
		m.setAccessible(true);
		m.invoke(obj, null);
		
		//Object obj=clazz3.newInstance();

	}

}
